package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author: 86182
 * @Date: 2021/8/31
 * @Time: 18:24
 * @Version:
 */
@RestController
@RequestMapping("supplier")
public class SupplierController {
    @Autowired
    private SupplierService supplierService;

    @PostMapping("list")
    public Map<String, Object> list(Integer page, Integer rows, String supplierName) {
        return this.supplierService.list(page,rows,supplierName);
    }

    @PostMapping("save")
    public ServiceVO save(Integer supplierId, Supplier supplier){
         this.supplierService.save(supplier,supplierId);
         return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS);
    }

    @PostMapping("delete")
    public ServiceVO delete(@RequestParam("ids") String ids){
        this.supplierService.delete(ids);
        return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS);
    }
}
